var app = getApp();
var constract = require('../../../utils/constract.js');
Page({
  data: {

  },
  onLoad: function (options) {
    console.log(options);

    var that = this;
    that.setData({//二维码分享过来的分享者信息
      id: options.id,
      avatar: options.avatar,
      name: options.name,
      dimension: options.qr_code,
      ouid: options.ouid
    })
    app.Verification(function (token) {
      wx.request({
        url: constract.index, //查看首页的名片信息
        header: { token: token },
        success: function (res) {
          var selfInfo = res.data.data;
          that.setData({
            selfInfo: selfInfo
          })
        }
      });
    })
  },

  goIndex: function () {
    var that = this;
    wx.switchTab({
      url: '/pages/index/index'
    })
  },
  addCard: function(){
    var that = this;
    wx.redirectTo({
      url: '/pages/add-card/add-card?avatar=' + that.data.selfInfo.avatar+'&name='+that.data.selfInfo.name
    })
  },

  // onShareAppMessage: function () {
  //   var that = this;
  //   return {
  //     title: '幸会！这是我名片请惠存！',
  //     path: '/pages/code/share-code/share-code?qr_code=' + that.data.dimension + '&avatar=' + that.data.avatar + '&name=' + that.data.name
  //   }
  // }
})